const App = getApp();
// 工具类
//import Util from '../../../utils/util.js';
Page({
  /**
   * 页面的初始数据
   */
  data: {
    isLogin: false,
    teamId:0,
    cate:1,   // 1积分，2捐款
    list:[],
    myNumber:0,
    myRanking:0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    let that = this;
    that.setData({
      isLogin: App.checkIsLogin(),
    });
    if (that.data.isLogin) {
      //获取服务队
      that.setData({
        teamId: App.checkTeam()
      });
      // 获取购物车列表
      that.getDataList();
    }
  },

 //获取数据列表
 getDataList(){
  let that = this;
  let obj = {is_team:0}
  if(that.data.switchChecked){
    obj.is_team = 1;
  }
  //1积分
  if(that.data.cate == 1){
    App._get('team/pointsRanking', obj, result => {
      that.setData({
        list: result.data.points_ranking,
        myNumber:result.data.my_team.myteam_points,
        myRanking:result.data.my_team.myteam_ranking,
      }); 
    });
  }
  //2捐款
  if(that.data.cate == 2){
    App._get('team/donateRanking', obj, result => {
      that.setData({
        list: result.data.points_ranking,
        myNumber:result.data.my_team.myteam_donate,
        myRanking:result.data.my_team.myteam_ranking,
      }); 
    });
  }
  
},

  // tab切换
  onChangeNews(e){
    let that = this;
    that.setData({
      cate: e.currentTarget.dataset.id
    }); 
    that.getDataList();
  },

  

})